<?php
namespace Home\Controller;
use Think\Controller;
class LoginController extends Controller {

    public function checkLogin(){// 赵明月-检验登录
       session('flag',null);
        $admin = M('clubadmin');
        $map = array();
        $map['c_tel']  = I('post.c_tel');
        $map['password']=md5(trim(I('post.password')));

        $admins=M('clubadmin');
        $c_tel=I('post.c_tel');
        $res1 = $admins->where("c_tel='$c_tel'")->find();
        $state=$admins->state;

        if($state=="1"){
        $res=$admin->where($map)->select();
        if($res==null){
            $this->error('用户名密码错误');
        }else {
           
            session("c_tel",$map['c_tel']);
          
            dump($_SESSION);
           redirect(U('Club/clublist'));

        }}else{$this->error('等待管理员审核');}


    
}
  
 public function reg(){ //俱乐部管理员注册，俱乐部添加

            /*$data=$_POST;
            $file=$_FILES;*/
            $clubs=M("club");
            $club_name=I('post.clubname');
            $club=$clubs->where("club_name='$club_name'")->find();
            if($club==null){
            $clubs->club_name=I('post.clubname');
            $clubs->club_intro=I('post.club_intro');
            $clubs->club_tele=I('post.club_tele');
            $clubs->club_address=I('post.club_address');
            $clubs->club_time=I('post.club_time');
            $clubs->uploaddate =  date("Y-m-d H:i:s"); // 设置用户的创建时间
            $clubs->club_pic="default.jpg";
         

            $date=M('clubadmin');
            $date->clubname=I('post.clubname');
            $date->c_tel=I('post.c_tel');
            $date->password=md5(trim(I('post.password')));
            $date->c_name=I('post.c_name');
            $date->state="0";
            if(false!=$clubs->add()&&false!=$date->add()){
             
                $this->success('注册成功!',U('clublogin'));
            }else{$this->error('数据错误');}
        }else{$this->error('俱乐部名已存在，请重新注册');}
    } 

    /*public function _initialize(){
        //  查看是否登录
        header("Content-type:text/html;charset=utf-8");
        if(ACTION_NAME!='index' && ACTION_NAME!='checkLogin'&& ACTION_NAME!='verify'){
            if(null==session('flag')|| session('flag')!='logok'){
                redirect(U('Club/clublist'));
            }
        }
    }

    function check_verify($code, $id = ''){
        $verify = new \Think\Verify();
        return $verify->check($code, $id);
    }

    public function verify(){
        ob_clean();
//        $config =    array(
//            'fontSize'    =>    30,    // 验证码字体大小
//            'length'      =>    3,     // 验证码位数
//            'useNoise'    =>    false, // 关闭验证码杂点
//            //'fontttf' => 'msyhbd.ttf',
//           
//
//            'useImgBg' => false,
//            //'useZh' => true,
//        );
//        $Verify = new \Think\Verify($config);
        $Verify = new \Think\Verify();
        $Verify->entry();
    }*/
}